﻿using NLog;

namespace WorkerService.App1.Workers;

public class Work2 : BackgroundService
{
    private Logger logger = LogManager.GetLogger("Work2");

    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        await Task.Run(() =>
        {
            Thread.Sleep(5000);
            logger.Info("work2 execute");
        });
    }

    public override Task StartAsync(CancellationToken cancellationToken)
    {
        logger.Info("work2 start");
        return base.StartAsync(cancellationToken);
    }

    public override Task StopAsync(CancellationToken cancellationToken)
    {
        logger.Info("work2 stop");
        return base.StopAsync(cancellationToken);
    }

    public override void Dispose()
    {
        base.Dispose();
        logger.Info("work2 dispose");
    }
}